//发送验证码

const nodemailer = require("nodemailer");
const createCode = require(path.resolve(basename,'utils/createCode.js'));

module.exports = async (req, res) => {
    // apgymciilmjzebif
    // console.log(req.body.email);
    let newCode = createCode();
    // console.log(newCode);

    let transporter = nodemailer.createTransport({
        host: "smtp.qq.com",
        port: 465,
        secure: true,
        auth: {
            user: '2467705585@qq.com',
            pass: 'apgymciilmjzebif',
        },
    });

    let info = await transporter.sendMail({
        from: '2467705585@qq.com',
        to: req.body.email, 
        subject: "商品管理系统", 
        html: `本次验证码为：<h3 style='color:red;'>${newCode}</h3>`, 
    });

    res.send({
        emailCode:newCode,
        msg:"邮件发送成功"
    })
}